<?php
    require_once('admin/inc/conexion.php');
    
    $email = $_SESSION['usuario'];
?>    
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
    <body>
        <?php
            $query = "SELECT * FROM clientes WHERE email='".$email;
            $ejecucion = mysql_query($query, $conexion);
            $result = mysql_fetch_array($ejecucion);
            
            $fechanac = explode("-",$result['fechanac']);
        ?>
        
        <form name="perfilm" action="perfilc.php" method="POST">
            Email:
            <br />
            <input name="email" type="email" value="<?php echo $email; ?>" />
            <br />
            <br />
            Nombre:
            <br />
            <input name="nombre" type="text" value="<?php echo $result['nombre']; ?>" />
            <br />
            <br />
            Apellidos:
            <br />
            <input name="apellidos" type="text" value="<?php echo $result['apellidos']; ?>" />
            <br />
            <br />
            Contrase&ntilde;a:
            <br />
            <input name="password" type="password" value="<?php echo $result['password']; ?>" />
            <br />
            <br />
            Fecha de nacimiento:
            <br />
            <select name="dia">
                <?php
                    for ($dia = 1;$dia <= 31;$dia ++){
                        if ($dia == $fechanac['2']){
                            echo "<option value='".$dia."' selected='selected'>$dia</option>";
                        }
                        else {
                            echo "<option value='".$dia."'>$dia</option>";
                        }
                    }
                ?>
            </select>
            <select name="mes">
                <?php
                    for ($mes = 1;$mes <= 12;$mes ++){
                        if ($mes == $fechanac['1']){
                            echo "<option value='".$mes."' selected='selected'>$mes</option>";
                        }
                        else {
                            echo "<option value='".$mes."'>$mes</option>";
                        }
                    }
                ?>
            </select>
            <select name="ano">
                <?php
                    $ano = date('Y');
                    
                    for ($i = $ano;$i >= $ano - 100;$i --){
                        if ($i == $fechanac['0']){
                            echo "<option value='".$ano."' selected='selected'>$ano</option>";
                        }
                        else {
                            echo "<option value='".$ano."'>$ano</option>";
                        }
                    }
                ?>
            </select>
            <br />            
            <br />
            <br />
            <br />
            <input name="emailv" type="hidden" value="<?php echo $email; ?>" />
            <input name="modificar" type="submit" />   
        </form>
    </body>
</html>
